package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.ProductBaseInfoEntity;
import com.xbongbong.saas.domain.entity.TransferProductEntity;
import com.xbongbong.saas.domain.entity.ext.ProductEntityExt;
import com.xbongbong.saas.domain.entity.ext.TransferEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/22 16:44
 * @since v1.0
 */
public interface TransferModel extends IModel<TransferEntityExt> {
    /**
     * 调拨单数据单条查询
     *
     * @param key    主键ID
     * @param corpid 公司ID
     * @return Integer
     * @author feng.zheng
     * @date 2019/2/15 20:27
     * @since v1.0
     */
    TransferEntityExt getByKey(Long key, String corpid);
    /**
     * 保存
     * @param transferEntity 调拨单实体
     * @author Jian.Wang
     * @date 2019/1/23 20:27
     * @since v1.0
     * @return Integer
     * @throws XbbException
     */
    Integer save(TransferEntityExt transferEntity) throws XbbException;

    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/2/27 21:52
     * @param list id列表
     * @param corpid 公司id
     * @param del   删除标志
     * @return Integer
     * @throws XbbException XbbException
     */
    Integer deleteBatch(List<Long> list, String corpid, Integer del) throws XbbException;

    /**
     * 单个删除
     * @author yuqian
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 批量更新
     * @param list 数据列表
     * @param corpid 公司id
     * @return Integer
     * @throws XbbException XbbException
     */
    Integer updateBatch(List<UpdateDataEntity> list, String corpid) throws XbbException;

    /**
     * 批量更新团队
     *
     * @param dataIdList
     * @param corpid
     * @param userId
     * @throws
     * @author long.rao
     * @date 2020-04-10 10:53
     */
    Integer batchUpdateOwner(List<Long> dataIdList, String corpid, String userId, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid,boolean needThrow) throws XbbException;

    List<String> getCorpids();

    @Override
    List findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 编辑时将获取数据格式化
     *
     * @param saasAnalysisDataDTO saas编辑数据
     * @param result               要返回的jsonobject
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/22 15:28
     */
    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;

    JSONObject formatSingleProduct(TransferProductEntity entity, ProductBaseInfoEntity productBaseInfoEntity);

    void getProductList(String corpid, List<TransferProductEntity> transferProducts, List<ProductBaseInfoEntity> productBaseInfoList, JSONObject data, Map<Long, ProductEntityExt> productMap) throws XbbException;

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, Boolean forProcess, Integer operate, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

}
